from urllib import request
from urllib import parse

data1 = {'wd': 'sql练习'}
search = parse.urlencode(data1)  # 编码 数据一定要是字典
print(search)
url = 'https://www.baidu.com/s?ie=utf-8&f=3&rsv_bp=1&rsv_idx=1&tn=78000241_11_hao_pg&' + search
resp = request.urlopen(url)
print(resp.read())

# 补充  字符串的编码
name = '石原里美'
print(parse.quote(name))

# 解码
print(parse.parse_qs(search))

